home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / partial2_cor.pro < prev    next >
Text File  |  1997-07-08  |  1KB  |  53 lines

  1. ; $Id: partial2_cor.pro,v 1.3 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ;  Copyright (c) 1991-1997, Research Systems Inc.  All rights
  4. ;  reserved. Unauthorized reproduction prohibited.
  5.  
  6.  
  7. function partial2_cor,X,Y,C
  8. ;+NODOCUMENT
  9. ; NAME: 
  10. ;     PARTIAL_COR2
  11. ;
  12. ; PURPOSE:
  13. ;    Compute the partial correlation coefficient between X and Y after
  14. ;    both have been adjusted for the variables in C
  15. ;
  16. ; CATEGORY:
  17. ;    Statistics.
  18. ;
  19. ; CALLING SEQUENCE: 
  20. ;    Result = PARTIAL_COR(X,Y,C)
  21. ;
  22. ; INPUTS:
  23. ;    X:    Column vector of R independent data values.
  24. ;
  25. ;    Y:    Column vector of R dependent data values.
  26. ;  
  27. ;    C:    Two-dimensional array with each column
  28. ;        containing data values corresponding to
  29. ;        an independent variable. Each column has
  30. ;        length R.
  31. ;
  32. ; OUTPUT:
  33. ;       The partial correlation coefficient.
  34. ;-
  35. SC = size(C)
  36. CNum = SC(1)
  37.  
  38. if CNum EQ 1 THEN BEGIN
  39.   P1 = Correlate(X,Y)
  40.   P2 = Correlate(X,C)
  41.   P3 = Correlate(Y,C)
  42.  
  43. ENDIF ELSE BEGIN
  44.   P1 = partial_cor(X,Y,C(0:CNum-2,*))
  45.   P2 = partial_cor(X,C(CNum-1,*),C(0:CNum-2,*))
  46.   P3 = partial_cor(Y,C(CNum-1,*),C(0:CNum-2,*))
  47.   ENDELSE
  48.  
  49. if ( P2 NE 1 and P3 NE 1) THEN          $
  50. return, (P1 - P2 * P3)/sqrt((1-P2^2) * (1 - P3^2)) $
  51. else return,0
  52. END
  53.